<?php


namespace App\Tpp\V1\Controllers\WechatPush;


use App\Tpp\V1\Controllers\BaseController;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Log;

class ComponentVerifyTicketController extends BaseController {
    
    /**
     * 验证票据（component_verify_ticket），在第三方平台创建审核通过后，微信服务器会向其 ”授权事件接收URL” 每隔 10 分钟以 POST 的方式推送 component_verify_ticket
     * 接收 POST 请求后，只需直接返回字符串 success。
     * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/component_verify_ticket.html
     */
    public function receiveTicket() {
        $openPlatform = Factory::openPlatform(config('wechat.open_platform.default'));
        
        $authUrl = $openPlatform->getPreAuthorizationUrl('https://easywechat.com/callback');
    
        Log::info('授权链接获取');
        Log::info($authUrl);
        
        return 'success';
    }
}